Repository navigation
🧪 test: restore inherited PYTHONPATH in native env-files test - #365
Open
sandrotosi wants to merge 3 commits into
Open
sandrotosi wants to merge 3 commits into
sandrotosi wants to merge 3 commits into
Conversation
pytest-dev#290 made test_native_env_files_override_ini forward the caller's PYTHONPATH to its pytest subprocess; the rewrite in pytest-dev#308 dropped it again, so the subprocess can't import pytest_env.plugin when the plugin is only reachable through PYTHONPATH, and all 24 cases fail. Prepend the caller's PYTHONPATH to the scenario's value; with PYTHONPATH unset the subprocess environment is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simplint's conditional-in-test rule rejects the conditional dict unpacking. Always set PYTHONPATH to the joined value instead: pytester's popen rebuilds PYTHONPATH with filter(None, ...), which drops an empty value, so the case without an inherited PYTHONPATH is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The news check needs a fragment or the skip news label, which only maintainers can apply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#290 made
test_native_env_files_override_iniforward the caller'sPYTHONPATHto its pytest subprocess, so packagers who reachpytest-envonly throughPYTHONPATHcan run it. The parametrization rewrite in #308 (640b2b9) dropped that again: the test clears the environment and passes only the scenario's ownPYTHONPATH, so the subprocess can't importpytest_env.pluginand all 24 cases fail:We hit it packaging 1.8.8 for Debian, where pybuild runs the suite against the built wheel through
PYTHONPATH.The test now prepends the caller's
PYTHONPATH, if set, to the scenario's value. WhenPYTHONPATHis unset, as under tox, the value is an empty string, which pytester drops when it builds the subprocess'sPYTHONPATH(filter(None, ...)inPytester.popen), so the subprocess environment is unchanged; the unset scenarios still see nopythonpath_markerand the set ones still see it.This changes only a test, so there's no new test. I added a
packagingnews fragment because I can't apply theskip newslabel; feel free to drop it and use the label instead, as in #290.Checked on Debian sid (Python 3.14.10, pytest 9.1.1, python-dotenv 1.2.1, pytest-mock 3.15.1), full suite:
mainPYTHONPATHonly (built wheel unpacked)PYTHONPATHunsetThe 24 failures on
mainare alltest_native_env_files_override_ini. The same change, carried as a Debian patch on 1.8.8, also passes the Debian build on Python 3.14 and 3.15.ruff0.17.5 (format and check) andsimplint0.14.2, the versions pinned in.pre-commit-config.yaml, pass; I haven't run the otherprekhooks.🤖 Generated with Claude Code